package com.ojoin.trade.supplyloan_core.web.service;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.web.service.BaseService;
import com.ojoin.trade.supplyloan_core.web.domain.*;
import org.springframework.data.domain.Pageable;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-28
 * Time: 上午10:20
 * To change this template use File | Settings | File Templates.
 */
public interface TbSlLoanCreditService extends BaseService<TbSlLoanCreditLog>  {
    /**
     *新增一条贷款记录
     * @param logvo
     * @throws BusinessException
     */
    public void insertTbSlLoanCreditLog(TbSlLoanCreditLog logvo)throws BusinessException;

    /**
     * 更新贷款的记录
     * @param parammap
     * @throws BusinessException
     */
    public int updateTbSlLoanCredit(Map<String,Object> parammap)throws BusinessException;

    /**
     * 根据join的用户主键查询该用户所有未还清的贷款记录
     * @param joinid
     * @return
     * @throws BusinessException
    */
    public List<TbSlLoanCreditLog> queryNotPayBackCreditLogByJoinid(int joinid,Pageable page)throws BusinessException;

    /**
     * 根据join用户查询所有未还清的贷款记录不分页
     * @param joinid
     * @return
     * @throws BusinessException
     */
    public  List<TbSlLoanCreditLog> queryNotPayBackCreditLogByJoinidNotPage(int joinid)throws BusinessException;

    /**
     * 查询所有未还清贷款的记录
     * @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLogVo> queryAllNotPayBackCreditLog(int userIdOfJoinOfCreditor)throws BusinessException;

    /**
     *批量更新贷款记录表的数据
     */
    public void updateBatchTbSlLoanCredit(List<TbSlLoanCreditLog> list)throws BusinessException;


    /**
     * 根据贷款的状态查询贷款的信息
     */
    public List<TbSlStatusCreditLogVo>  queryCreditLogByStatus(int status,int userIdOfJoinOfCreditor, Pageable page)throws BusinessException;

    /**
     * 根据id查询贷款信息
     */
    public TbSlLoanCreditLog queryCreditLogById(int id)throws BusinessException;

    /**
     * genjjoin id查询该商户已申请的贷款总额
     * @param id
     * @return
     * @throws BusinessException
     */
    public String querySumApplyLoanByJoinid(int id) throws BusinessException;

    /**
     * 贷款日志表的自动计息,包括正常利息，展息和罚息三个部分
     */
    public void updateCaculateCreditFee()throws BusinessException;


    /**
     * 查询保理员贷款的审核任务
     * @return
     * @throws BusinessException
     */
    public List<SlLoanTodoTaskVO> queryToDoTask(Pageable page)throws BusinessException;

    /**
     * 拒绝贷款
     * @param id
     * @param memo
     * @throws BusinessException
     */
    public void updateForRefuseLoan(String id, String memo)throws  BusinessException;

    /**
     * 根据设置的条件对账
     * @param map
     * @param page
     * @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLogVo> queryPayBackCreditLogByCause(Map map, Pageable page) throws BusinessException;

    /**
     * 查询用户已还清的贷款
     * @param joinid
     * @param page
     * @return
     * @throws BusinessException
     */
    public  List<TbSlLoanCreditLog> queryPaybackByJoinid(int joinid,Pageable page)throws BusinessException;

    /**
     * 查询用户的已贷款次数(排除-1已取消和3已拒绝的申请记录)
     * @param joinuserid
     * @return
     * @throws BusinessException
     */
    public String selectCreditLoanCountByJoinid(int joinuserid) throws BusinessException;

    /**
     * 查询用户的未完成的贷款次数(查询0提交申请 1申请放款，2初审通过的申请记录)
     * @param joinuserid
     * @return
     * @throws BusinessException
     */
    public String selectNotcompleteCreditLoanByJoinid(int joinuserid) throws BusinessException;
    
    /**
     * 根据id的数值批量查询贷款记录
     * @param idlist
     * @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLog> queryListByIds(List<Integer> idlist)throws BusinessException;

    /**
     * 根据join用户查询用户的申请贷款记录
     * @param joinid
     * @param page
     * @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLog> queryApplyByJoinid(int joinid,Pageable page)throws BusinessException;

    /**
     * 根据id删除数据
     */
    public void deleteCreditLog(int id)throws BusinessException;

    public void updateForCancelCreditLog()throws BusinessException;

    /**
     * 根据用户查询贷款数据
     * @param joinid
     * @param page
     * @return
     * @throws BusinessException
     */

    public List<TbSlLoanCreditLog> queryCreditByJoinid(int joinid, Pageable page) throws BusinessException;

    /**
     * 批量更新贷款的融资申请书地址
     * @param material
     * @throws BusinessException
     */
    public void updateBatchForFile(List<TbSlLoanCreditLog> list, String material) throws BusinessException;


    public TbSlNotPayBackCreditForFront queryNotPayback( int joinid,Pageable page)throws BusinessException;

    /**
     *        批量取消
     *        **  * @param idlist
     * @throws BusinessException
     */
    public void updateBatchCancel(List<Integer> idlist)throws BusinessException;

    public void lockById(int id)throws BusinessException;

    public List<TbSlLoanCreditLogForFront> queryTbSlLoanCreditLogForFront(int userIdOfIPayNowOfDebtor) throws BusinessException;

    /**
     *计息表加锁
     *  * @throws BusinessException
     */
    public void lockTable()throws BusinessException;

    /**
     *保理员后台查询商户的贷款记录
     * @param userIdOfIPayNowOfDebtor
     * @return
     * @throws BusinessException
     */
    public List<TbSlNotPayBackCredit> queryCreditNotPayBackForSl(int userIdOfIPayNowOfDebtor)throws BusinessException;

    public List<TbSlLoanCreditLog> queryNotPayBack()throws BusinessException;

    /**暂停平台同时取消
     ** @param idOfPlatform
     * @throws BusinessException
     */
    public void cancelForPausedPlatform(Integer idOfPlatform) throws BusinessException;

    /**查询快到期和展期的贷款
     * @param userIdOfJoinOfDebtor
     * @param page
     * @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLog> queryWillExpire(Integer userIdOfJoinOfDebtor,Pageable page) throws BusinessException;

    /**
     * 查询需要展期的
     * @param userIdOfJoinOfCreditor
     * @param page
     * @return
     * @throws BusinessException
     */
    public List<TbSlStatusCreditLogVo> queryRenewedCredit(Integer userIdOfJoinOfCreditor,Integer userIdOfJoinOfDebtor,Integer idOfPlatform,String begintime,String endtime,Pageable page) throws BusinessException;

    /**保理员后台查询调差价的贷款信息
     *  * @param parammap
     * @param page
     * @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLogVo> queryCreditForFloat(Map<String,Object> parammap,Pageable page)throws BusinessException;

    /**查询用户的展期贷款信息
     ** @param joinid
     * @return
     * @throws BusinessException
     */
    public List<TbSlCreditLogForExcelVO> queryCreditForExcel(int joinid) throws BusinessException;

    /**查询平台是否有欠款
     * @param platform
     * @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLog> queryNotPayBackByPlatform(int platform)throws BusinessException;

    /**
     * 查询贷款数据和贷款总表关联数据
     * @param id
     * @return
     * @throws BusinessException
     */
    public TbSlStatusCreditLogVo queryStatusCreditLogVo(int id) throws BusinessException;


    public List<TbSlLoanCreditLog> queryCodeById(List<Integer> list) throws BusinessException;

    public List<TbSlLoanCreditLog> queryTsById(List<Integer> idlist)throws BusinessException;

    public TbSlStatusCreditLogVo queryInfoById(Integer id) throws BusinessException;

    public void updateCreditLogForBatch(Map<String, Object> map) throws BusinessException;

    public void updateForCancelCredit(Integer processid) throws BusinessException;

    public void updateFileByProcessid(Integer process_info_id,String material) throws BusinessException;
    public List<TbSlStatusCreditLogVo> queryCreditByProcessid(Integer process_info_id) throws BusinessException;

    public void queryNeedMessage() throws BusinessException;

    /**查询贷款快到期的数据
     ** @return
     * @throws BusinessException
     */
    public List<TbSlLoanCreditLogVo> queryWillExpireCreditForOperator(Pageable pageable) throws BusinessException ;

    public List<SLLoanBillBaseInfoVo> querySlloanBillVo(String begintime,String endtime,Integer userIdOfJoinOfDebtor,Integer userIdOfJoinOfCreditor,Pageable pageable)throws BusinessException;

    public SLLoanBillVo querySlLoanBillSumvo(String begintime,String endtime,Integer userIdOfJoinOfDebtor,Integer userIdOfJoinOfCreditor)throws BusinessException;
}